<template>
  <div id="recruitTableJH">
    {{ returnTextFun() }}
    <el-popover class="item"
      :open-delay="600"
      placement="top"
      trigger="hover"
      content="该人员在历年招聘人员信息库中不存在"
      v-if="!testTable||testTable.length===0||!testTable.find(item=>item.idCardNo===rowData.idCardNo)">
      <el-button slot="reference" type="text" icon="el-icon-warning" />
    </el-popover>
    <template v-else-if="columnName!=='idCardNo'">
      <el-popover class="item"
        :open-delay="600"
        placement="top"
        trigger="hover"
        :content="contentText"
        @show="contentTextFun"
        v-if="isShowFun()">
        <el-button slot="reference" type="text" icon="el-icon-warning" />
      </el-popover>
    </template>
  </div>
</template>
<script>
export default {
  props: {
    testTable: null,
    columnName: '',
    rowData: null,
    theYear: null,
    flag: ''
  },
  data () {
    return {
      contentText: '加载中...'
    }
  },
  watch: {
    testTable (val) {
    },
    columnName (val) {
    },
    rowData (val) {
    },
    theYear (val) {
    }
  },
  methods: {
    returnTextFun () {
      if (this.flag === '1') {
        if (this.rowData[this.columnName] === 1) {
          return '京内'
        } else {
          return '京外'
        }
      }
      if (this.flag === '2') {
        if (this.rowData[this.columnName] === 1) {
          return '是'
        } else {
          return '否'
        }
      }
      return this.rowData[this.columnName]
    },
    contentTextFun () {
      const obj = this.testTable.find(item => item.idCardNo === this.rowData.idCardNo)
      if (this.columnName === 'receiveYear') this.contentText = '该人员在历年招聘人员信息库中接收年份为' + obj.theYear + '年'
      if (this.columnName === 'unitName') this.contentText = '该人员在历年招聘人员信息库中单位名称为' + obj.unitName
      if (this.columnName === 'department') this.contentText = '该人员在历年招聘人员信息库中部门名称为' + obj.department
      if (this.columnName === 'post') this.contentText = '该人员在历年招聘人员信息库中工作岗位为' + obj.post
      if (this.columnName === 'realName') this.contentText = '该人员在历年招聘人员信息库中姓名为' + obj.realName
      if (this.columnName === 'inBeijing') this.contentText = '该人员在历年招聘人员信息库中生源为' + obj.inBeijingText
      if (this.columnName === 'school') this.contentText = '该人员在历年招聘人员信息库中院校为' + obj.school
      if (this.columnName === 'major') this.contentText = '该人员在历年招聘人员信息库中所学专业为' + obj.major
      if (this.columnName === 'inPost') this.contentText = '该人员在历年招聘人员信息库中是否在岗为' + obj.inPostText
    },
    isShowFun () {
      let flag = ''
      if (this.columnName === 'receiveYear') {
        flag = this.testTable.find(item => item.idCardNo === this.rowData.idCardNo)['theYear'] !== this.rowData['receiveYear']
      } else {
        flag = this.testTable.find(item => item.idCardNo === this.rowData.idCardNo)[this.columnName] !== this.rowData[this.columnName]
      }
      return flag
    }
  },
  mounted () {
  }
}
</script>
